import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description TODO
 * @Date 2022/3/28 10:45
 * @Author 轻歌
 */
public class PuncDiffSetPair {
    private int v;
    private int k1;
    private int k2;
    private int e;
    private int lamada;  //lambda
    private int[] vSet;
    private int[] uSet;
    private int[] pSet;
    private int[] eSet;
    private int[] u1Set;
    private int[] wSet;
    private int[] w1Set;

    public PuncDiffSetPair() {
    }

    public PuncDiffSetPair(int v, int k1, int k2, int e, int lamada) {
        this.v = v;
        this.k1 = k1;
        this.k2 = k2;
        this.e = e;
        this.lamada = lamada;
        int[] vSet = new int[v];
        for (int i = 0; i < v; i++) {
            vSet[i] = i;
        }
        this.vSet = vSet;
    }

    public PuncDiffSetPair(int[] nums){
        this.v = nums[0];
        this.k1 = nums[1];
        this.k2 = nums[2];
        this.e = nums[3];
        this.lamada = nums[4];
        int[] vSet = new int[v];
        for (int i = 0; i < v; i++) {
            vSet[i] = i;
        }
        this.vSet = vSet;
    }

    public boolean isPuncDiffSetPair(){
        //todo 根据定义 构造差表 判断是否是屏蔽差集偶
        int[] countU = new int[v];
        int[] countW = new int[v];
        int[] count = new int[v];
        for (int u : uSet){
            for (int u1 : u1Set){
                countU[(u - u1 + v) % v]++;
            }
        }
        for (int w : wSet){
            for (int w1: w1Set){
                countW[(w - w1 + v) % v]++;
            }
        }

        for (int i = 0; i < v; i++){
            count[i] = countU[i] + countW[i];
        }

//        for (int i : count){
//            if (i != lamada){
//                return false;
//            }
//        }
        for (int i = 1; i<count.length;i++){
            if (count[i] != lamada){
                return false;
            }
        }

        return true;
    }

    public int getV() {
        return v;
    }

    public void setV(int v) {
        this.v = v;
    }

    public int getK1() {
        return k1;
    }

    public void setK1(int k1) {
        this.k1 = k1;
    }

    public int getK2() {
        return k2;
    }

    public void setK2(int k2) {
        this.k2 = k2;
    }

    public int getE() {
        return e;
    }

    public void setE(int e) {
        this.e = e;
    }

    public int getLamada() {
        return lamada;
    }

    public void setLamada(int lamada) {
        this.lamada = lamada;
    }

    public int[] getvSet() {
        return vSet;
    }

    public void setvSet(int[] vSet) {
        this.vSet = vSet;
    }

    public int[] getuSet() {
        return uSet;
    }

    public void setuSet(int[] uSet) {
        this.uSet = uSet;
    }

    public int[] getpSet() {
        return pSet;
    }

    public void setpSet(int[] pSet) {
        this.pSet = pSet;
    }

    public int[] geteSet() {
        return eSet;
    }

    public void seteSet(int[] eSet) {
        this.eSet = eSet;
    }

    public int[] getU1Set() {
        //todo U1 = U - U ∩ P
        int[] u1Set = ArrayUtil.deleteSame(uSet, pSet);

        return u1Set;
    }

    public void setU1Set(int[] u1Set) {
        this.u1Set = u1Set;
    }

    public int[] getwSet() {
        //todo W = V - U
        int[] wSet = ArrayUtil.deleteSame(vSet, uSet);
        return wSet;
    }

    public void setwSet(int[] wSet) {
        this.wSet = wSet;
    }

    public int[] getW1Set() {
        //todo W1 = W - W ∩ P
        int[] w1Set = ArrayUtil.deleteSame(wSet, pSet);
        return w1Set;
    }

    public void setW1Set(int[] w1Set) {
        this.w1Set = w1Set;
    }

    @Override
    public String toString() {
        return "PuncDiffSetPair{" +
                "v=" + v +
                ", k1=" + k1 +
                ", k2=" + k2 +
                ", e=" + e +
                ", lamada=" + lamada +
                ", uSet=" + Arrays.toString(uSet) +
                ", pSet=" + Arrays.toString(pSet) +
                ", eSet=" + Arrays.toString(eSet) +
                '}';
    }
}
